package com.fishing.controller;

import QL.QLClient;
import com.fishing.entity.Record;
import com.fishing.service.EditLogService;
import com.fishing.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class RoomDataController {

    private static QLClient client = new QLClient();

    @Autowired
    RecordService recordService;

    @Autowired
    EditLogService editLogService;

    //region 查询血池变化
    @ResponseBody
    @RequestMapping("room/selectPool")
    public Map<String,Object> selectPool(Integer roomId,String startTime,String endTime,Integer pageIndex, Integer pageCount){
        Map<String,Object> map = new HashMap<>();
        pageIndex = (pageIndex - 1) * pageCount;
        System.out.println(startTime+" : "+endTime);
        List<Record> records = recordService.selectAll(roomId,startTime,endTime,pageIndex,pageCount);
        Integer count = recordService.selectCount();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (Record record : records) {
            record.setTimeFormat(simpleDateFormat.format(record.getRecordtime()));
        }
        map.put("data", records);
        map.put("count",count);
        map.put("status", "200");
        map.put("message", "");
        return map;
    }
    //endregion
}
